<?php

namespace App\Models;

use App\Models\airline\base\BanModel;
use App\Models\airline\base\ContainerModel;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Eloquent\Model as BaseModel;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;

//仓库 上板管理
class DepotBanModel extends BaseModel
{
    use HasFactory, SoftDeletes;

    protected $table = 't_depot_ban';

    protected $primaryKey = 'id';

    public $timestamps = true;

    const CREATED_AT = 'created_at';
    
    const UPDATED_AT = null;

    protected $guarded = [];

    protected $hidden = [
    ];

    //创建人
    public function create_admin(): BelongsTo {
        return $this->belongsTo(AdminModel::class, 'created_admin_id');
    }

    //提单
    public function take_order(): BelongsTo {
        return $this->belongsTo(TakeOrderModel::class, 'take_order_id');
    }

    //板
    public function container(): BelongsTo {
        return $this->belongsTo(ContainerModel::class, 'container_id');
    }

    //order_items
    public function items(): HasMany {
        return $this->hasMany(DepotBanItemModel::class, 'depot_ban_id');
    }

    //航班
    public function flight(): BelongsTo {
        return $this->belongsTo(FlightModel::class, 'flight_id');
    }

}
